'use strict';

angular.module('snPaas_om').service('userStore',['SpHttp','$q','baseUrl',function($http,$q,baseUrl){
	
	var getUsers = function(page){
		var deferred = $q.defer();
		$http.get('/rest/user/list',{params:{page:page}}).success(function(data,status){
			var p = data.data.pageCount;
			var page = [];
			for(var i = 1;i<=p;i++){
				page.push(i);
			}
			data.data.pageCount = page;
			deferred.resolve(data.data);
		});
		return deferred.promise;
	};
	var getDetail = function(userId){
		var deferred = $q.defer();
		$http.get('/rest/user/detail',{params:{userId:userId}}).success(function(data,status){
			deferred.resolve(data.data);
		});
		return deferred.promise;
	};

	return {
		getUsers:getUsers,
		getDetail:getDetail
	};
}]);